#include <stdio.h>
#include <windows.h>
#include "http_packet_parsing.h"

void clear_buf(int8_t *buf, int len)
{
	while (len--)
	{
		*buf = 0;
		buf++;
	}
}

int main(void)
{
	char buf[500] = {
"123fdsFsFDasd4324HTTP/1.1 200 OK\r\n\
Server: openresty\r\n\
Date: Wed, 09 Nov 2016 08:29:47 GMT\r\n\
Content-Type: application/json\r\n\
Content-Length: 56\r\n\
Connection: keep-alive\r\n\
\r\n\
{\"error\":0,\"reason\":\"ok\",\"IP\":\"54.223.34.73\",\"port\":443}56468"};


	char tmp_buf[500] = { 0 };

	if (check_http_packet_rece_finish(buf, 500))
	{
		get_http_packet_content(buf,CONTENT_LENGTH,tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf,500);
		get_http_packet_content(buf, CONTENT_TYPE, tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf, 500);
		get_http_packet_content(buf, CONNECTION, tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf, 500);
		get_http_packet_content(buf, SERVER, tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf, 500);
		get_http_packet_content(buf, DATE, tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf, 500);
		get_http_packet_content(buf, HTTP_HEAD, tmp_buf);
		printf("%s\n", tmp_buf);
		clear_buf(tmp_buf, 500);
		get_http_packet_content(buf, DATA, tmp_buf);
		printf("%s\n", tmp_buf);
	}

	while (1)
	{

	}
}